package com.sx.ad.advice;

import com.sx.ad.exception.AdException;
import com.sx.ad.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zkx
 * @Date 2024/8/22 13:31
 */
@RestControllerAdvice
public class GlobalExceptionAdvice {

	@ExceptionHandler(value = AdException.class)
	public CommonResponse<String> handlerAdException(HttpServletRequest request, AdException ex){

		CommonResponse<String> response = new CommonResponse<>(-1, "business error");
		response.setData(ex.getMessage());
		return response;
	}
}
